package ahblue.cn.tanzi.model.user;

import android.content.Context;
import android.widget.Toast;

import java.util.List;

import ahblue.cn.tanzi.data.source.ApiCallback;
import ahblue.cn.tanzi.data.source.RemoteRepository;
import ahblue.cn.tanzi.util.PinkJSON;

/**
 * @author pink-jackstraw
 * @date 2018/11/10
 * @describe
 */
public class UserModel  {

    /**
     * member_id : 1
     * member_name : xuping
     * member_mobile : 18956583792
     * pass_word : e10adc3949ba59abbe56e057f20f883e
     * member_level : 0
     * wx_openid : 23
     * add_time : 1542030228
     * invite_code : 214532
     * inviter : RA4HLQ
     * member_deposit : 0
     * official_personnel : 0
     * member_avatar : https://xmzjvip.b0.upaiyun.com/xmzj/73511515754795248.png
     * circle_id : 33,3,4,
     * identity_card :
     * bank_card :
     * alipay_account :
     * real_name :
     * profile :
     * team_url=http://tanzi.cpicollect.com/member/member_index/team_index?token249cd21211df18160bacfd959531c583
     */

    public String member_id;
    public String member_name;
    public String member_mobile;
    public String pass_word;
    public String member_level;
    public String wx_openid;
    public String add_time;
    public String invite_code;
    public String team_url;
    public String inviter;
    public String member_deposit;
    public String official_personnel;
    public String member_avatar;
    public List<String> circle_id;
    public String identity_card;
    public String bank_card;
    public String alipay_account;
    public String real_name;
    public String profile;
    public int has_real;
    public String expired_time;

    /**
     * 获取用户详情信息
     * @param context
     * @param token
     * @param loginListener
     */
    public static void getUserInfo(final Context context,String token, final UserInfoLoginStatus loginListener){
        RemoteRepository repo = RemoteRepository.getsInstance();
        repo.getUserInfo(token, new ApiCallback<UserModel>(){
            @Override
            public void onSuccess(UserModel data) {
                LoginResultModel.saveUserInfo(context,PinkJSON.toJSON(data).toString());
                if (null!=loginListener){
                    loginListener.conver(data);
                }
            }
            @Override
            public void onFailed(String errorMsg) {
                if (null!=loginListener){
                    loginListener.conver(null);
                }
            }
        });
    }

    //--------------------------------------------------------------------------------------------------

    public interface UserInfoLoginStatus {
        void conver(UserModel model);
    }


}
